package wiiWired.controller.console.wizard;

import javax.swing.table.AbstractTableModel;

import wiiWired.controller.data.NameGetter;

public class WizardModel extends AbstractTableModel
{
	private static final long serialVersionUID = 1L;

	public static final String[] COLUMNS = { "Bluetooth Address", "Name" };

	@Override
	public int getColumnCount()
	{
		return COLUMNS.length;
	}

	@Override
	public int getRowCount()
	{
		return NameGetter.getData().length;
	}

	public String getColumnName(int columnIndex)
	{
		return COLUMNS[columnIndex];
	}

	public boolean isCellEditable(int rowIndex, int columnIndex)
	{
		return (columnIndex == 1);
	}

	public void setValueAt(Object aValue, int rowIndex, int columnIndex)
	{
		String[][] data = NameGetter.getData();
		data[rowIndex][1] = aValue.toString();
		
		NameGetter.writeToFile(data);
	}
	
	/**
	 * Returns the contents of a cell (for JTable)
	 */
	@Override
	public Object getValueAt(int row, int col)
	{
		return NameGetter.getData()[row][col];
	}


}
